Skip to content

fix: Cancel computation when Thread has been interrupted#1495

Merged
rubenporras merged 1 commit intoeclipse-lsp4e:mainfrom
FlorianKroiss:handle-interrupt-during-completion
Jan 30, 2026
Merged

fix: Cancel computation when Thread has been interrupted#1495
rubenporras merged 1 commit intoeclipse-lsp4e:mainfrom
FlorianKroiss:handle-interrupt-during-completion

Conversation

@FlorianKroiss
Copy link
Copy Markdown
Contributor

This is similar to #1486, but here our Thread is informed directly via org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.cancelFutures(), which interrupts all running completion computations.

We spotted this rare problem within our application and noticed the following Error being logged:

ERROR 2026-01-28 08:50:18.708 [org.eclipse.jface.text-worker-1] org.eclipse.equinox.logger - InterruptedException
java.lang.InterruptedException: null
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
	at org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor.computeCompletionProposals(LSContentAssistProcessor.java:177)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$10(AsyncCompletionProposalPopup.java:385)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$9(AsyncCompletionProposalPopup.java:384)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$11(AsyncCompletionProposalPopup.java:419)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

@FlorianKroiss FlorianKroiss force-pushed the handle-interrupt-during-completion branch from c778c29 to 29278aa Compare January 29, 2026 14:22
@rubenporras
Copy link
Copy Markdown
Contributor

@FlorianKroiss , I see that the PR will not break anything but I am surprise because I see that CompletableFuture.cancel according to documentation and implementation will never cancel a running future. How is that the InterruptedException is thrown? Could you explain it?

@FlorianKroiss
Copy link
Copy Markdown
Contributor Author

FlorianKroiss commented Jan 29, 2026

@rubenporras
You are right, CompletableFuture.cancel does not interrupt.
However, the CompletableFuture is actually a wrapper around regular a Future, see org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.submitInterruptible(Callable<T>, ExecutorService).
If the CompletableFuture is cancelled, then the underlying Future (where our code runs) is also cancelled, and this cancellation causes an interrupt.

@rubenporras
Copy link
Copy Markdown
Contributor

@rubenporras rubenporras merged commit 7abcc39 into eclipse-lsp4e:main Jan 30, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants